<template>
    <div v-if="item.children" class="m-name">
       <span class="m-title"> {{ $i18(item.title) }}</span>
        <template class="m-child">
            <div v-for="itemChild in item.children" class="m-itemChild">
                <MSubTableLatticeName :item="itemChild"></MSubTableLatticeName>
            </div>
        </template>
    </div>
  <th class="sub-table-list-th m-name" v-else-if="subShowControl(item)" >
        <MFormTitle
            v-if="item.controlConfig.control.showTitle"
            :name="item.controlConfig.name"
            :metadata="item.controlConfig"
            :rules="item.controlConfig.rules"
            :isDialog="isDialog"
        ></MFormTitle>
  </th>
</template>

<script>
import SubTable from "./SubTable.js"
export default {
    name: "MSubTableLatticeName",
    mixins: [SubTable],
    props:{'item':{},'isDialog':{default:true}},
    data(){
        return{

        }
    },
    created(){

    },
    methods:{
        subShowControl(item){
            let conditionConfig = item.colHideConfig;
            if (!conditionConfig) {
                return true;
            }
            if(conditionConfig.isHide){
                return false
            }
            if(!conditionConfig.hideCondition){
                return true;
            }
            let {hideCondition} = conditionConfig;
            if (hideCondition.indexOf('return') === -1) {
                hideCondition = 'return ' + hideCondition;
            }
            let fn = new Function('row',hideCondition);
            return  !fn.call(this.formVm)
        },
    }
}
</script>

<style scoped>
.m-child{
    display: flex;
}
.m-name{
   line-height: 2rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: normal;
    text-align: center;
}
.m-name>>>.MFormTitle{
    width: 10rem!important;
}
.m-title{
    display: block;
    padding-bottom: 0.4rem;
    border-bottom: 1px solid rgb(228, 231, 237);
    font-weight: normal;
}
.m-itemChild{
    min-width: 10rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-left: 1px solid rgb(228, 231, 237);
}
.m-itemChild:first-child{
    border: none;
}
</style>
